package cn.tedu.controller;

import cn.tedu.pojo.Car;
import cn.tedu.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Amos
 * @date 2021/9/14
 */

@RestController
@RequestMapping("car")
@CrossOrigin
public class CarController {
    @Autowired
    private CarService carService; //使用了接口，这样更好，多态！

    @RequestMapping("get")
    public List<Car> selecList() {
        return carService.selectList(); // [{"id":1,"name":"BMW","color":"red","price":9.9},{"id":2,"name":"Audi","color":"black","price":1.5}]
    }
}
